﻿
var url = "/home/as/AjaxHomeCommon.aspx?r=" + Math.random();

function PutInShoppingCart(goodsid) {
    var data = "goodsid=" + goodsid;
    var posttype = "GET";
    var success = function (ret) {
        if (ret) {
            if (!confirm("提示：商品已经放到购物车，继续购物？")) {
                location.href = "/home/orderinfo.aspx";
            }
        }
        else {
            alert("系统提示：操作失败，失败原因（" + ret.Message + "）");
        }
    };
    AjaxPostMyfavorite("PutInShoppingCart", data, success, posttype);
}

function CancelFav(goodsid) {
    if (!confirm("提示：确认要删除该关注商品吗？")) {
        return;
    }
    var data = "goodsid=" + goodsid;
    var posttype = "GET";
    var success = function (ret) {
        if (ret) {
           // $("#g" + goodsid).slideUp(function () { $(this).remove(); });
            location.reload();
        }
        else {
            alert("系统提示：操作失败，失败原因（" + ret.Message + "）");
        }
    };
    AjaxPostMyfavorite("CancelFavorite", data, success, posttype);
}

function AjaxPostMyfavorite(Action, data, success, posttype) {
    var ajaxurl = url + "&Action=" + Action;
    $.ajax(
    {
        type: posttype,
        url: ajaxurl,
        data: data,
        datatype: "json",
        success: success
    });
}